home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 26.zip / BS1 part 26 / Aztec C v5.2a disk 4.adf / 204inc_h.lzh / dos / dosextens.h < prev    next >
C/C++ Source or Header  |  1991-03-14  |  16KB  |  484 lines

  1. #ifndef DOS_DOSEXTENS_H
  2. #define DOS_DOSEXTENS_H
  3. /*
  4. **    $Filename: dos/dosextens.h $
  5. **    $Release: 2.04 $
  6. **    $Revision: 36.35 $
  7. **    $Date: 91/02/25 $
  8. **
  9. **    DOS structures not needed for the casual AmigaDOS user
  10. **
  11. **    (C) Copyright 1985,1986,1987,1988,1989,1990 Commodore-Amiga, Inc.
  12. **        All Rights Reserved
  13. */
  14.  
  15. #ifndef EXEC_TASKS_H
  16. #include "exec/tasks.h"
  17. #endif
  18. #ifndef EXEC_PORTS_H
  19. #include "exec/ports.h"
  20. #endif
  21. #ifndef EXEC_LIBRARIES_H
  22. #include "exec/libraries.h"
  23. #endif
  24. #ifndef EXEC_SEMAPHORES_H
  25. #include "exec/semaphores.h"
  26. #endif
  27. #ifndef DEVICES_TIMER_H
  28. #include "devices/timer.h"
  29. #endif
  30.  
  31. #ifndef DOS_DOS_H
  32. #include "dos/dos.h"
  33. #endif
  34.  
  35. /* All DOS processes have this structure */
  36. /* Create and Device Proc returns pointer to the MsgPort in this structure */
  37. /* dev_proc = (struct Process *) (DeviceProc(..) - sizeof(struct Task)); */
  38.  
  39. struct Process {
  40.     struct  Task    pr_Task;
  41.     struct  MsgPort pr_MsgPort; /* This is BPTR address from DOS functions  */
  42.     WORD    pr_Pad;        /* Remaining variables on 4 byte boundaries */
  43.     BPTR    pr_SegList;        /* Array of seg lists used by this process  */
  44.     LONG    pr_StackSize;    /* Size of process stack in bytes        */
  45.     APTR    pr_GlobVec;        /* Global vector for this process (BCPL)    */
  46.     LONG    pr_TaskNum;        /* CLI task number of zero if not a CLI        */
  47.     BPTR    pr_StackBase;    /* Ptr to high memory end of process stack  */
  48.     LONG    pr_Result2;        /* Value of secondary result from last call */
  49.     BPTR    pr_CurrentDir;    /* Lock associated with current directory   */
  50.     BPTR    pr_CIS;        /* Current CLI Input Stream            */
  51.     BPTR    pr_COS;        /* Current CLI Output Stream            */
  52.     APTR    pr_ConsoleTask;    /* Console handler process for current window*/
  53.     APTR    pr_FileSystemTask;    /* File handler process for current drive   */
  54.     BPTR    pr_CLI;        /* pointer to CommandLineInterface        */
  55.     APTR    pr_ReturnAddr;    /* pointer to previous stack frame        */
  56.     APTR    pr_PktWait;        /* Function to be called when awaiting msg  */
  57.     APTR    pr_WindowPtr;    /* Window for error printing            */
  58.  
  59.     /* following definitions are new with 2.0 */
  60.     BPTR    pr_HomeDir;        /* Home directory of executing program        */
  61.     LONG    pr_Flags;        /* flags telling dos about process        */
  62.     void    (*pr_ExitCode)();    /* code to call on exit of program or NULL  */
  63.     LONG    pr_ExitData;    /* Passed as an argument to pr_ExitCode.    */
  64.     UBYTE   *pr_Arguments;    /* Arguments passed to the process at start */
  65.     struct MinList pr_LocalVars; /* Local environment variables            */
  66.     ULONG   pr_ShellPrivate;    /* for the use of the current shell        */
  67.     BPTR    pr_CES;        /* Error stream - if NULL, use pr_COS        */
  68. };  /* Process */
  69.  
  70. /*
  71.  * Flags for pr_Flags
  72.  */
  73. #define    PRB_FREESEGLIST        0
  74. #define    PRF_FREESEGLIST        1
  75. #define    PRB_FREECURRDIR        1
  76. #define    PRF_FREECURRDIR        2
  77. #define    PRB_FREECLI        2
  78. #define    PRF_FREECLI        4
  79. #define    PRB_CLOSEINPUT        3
  80. #define    PRF_CLOSEINPUT        8
  81. #define    PRB_CLOSEOUTPUT        4
  82. #define    PRF_CLOSEOUTPUT        16
  83. #define    PRB_FREEARGS        5
  84. #define    PRF_FREEARGS        32
  85.  
  86. /* The long word address (BPTR) of this structure is returned by
  87.  * Open() and other routines that return a file.  You need only worry
  88.  * about this struct to do async io's via PutMsg() instead of
  89.  * standard file system calls */
  90.  
  91. struct FileHandle {
  92.    struct Message *fh_Link;     /* EXEC message          */
  93.    struct MsgPort *fh_Port;     /* Reply port for the packet */
  94.    struct MsgPort *fh_Type;     /* Port to do PutMsg() to
  95.                   * Address is negative if a plain file */
  96.    LONG fh_Buf;
  97.    LONG fh_Pos;
  98.    LONG fh_End;
  99.    LONG fh_Funcs;
  100. #define fh_Func1 fh_Funcs
  101.    LONG fh_Func2;
  102.    LONG fh_Func3;
  103.    LONG fh_Args;
  104. #define fh_Arg1 fh_Args
  105.    LONG fh_Arg2;
  106. }; /* FileHandle */
  107.  
  108. /* This is the extension to EXEC Messages used by DOS */
  109.  
  110. struct DosPacket {
  111.    struct Message *dp_Link;     /* EXEC message          */
  112.    struct MsgPort *dp_Port;     /* Reply port for the packet */
  113.                  /* Must be filled in each send. */
  114.    LONG dp_Type;         /* See ACTION_... below and
  115.                   * 'R' means Read, 'W' means Write to the
  116.                   * file system */
  117.    LONG dp_Res1;         /* For file system calls this is the result
  118.                   * that would have been returned by the
  119.                   * function, e.g. Write ('W') returns actual
  120.                   * length written */
  121.    LONG dp_Res2;         /* For file system calls this is what would
  122.                   * have been returned by IoErr() */
  123. /*  Device packets common equivalents */
  124. #define dp_Action  dp_Type
  125. #define dp_Status  dp_Res1
  126. #define dp_Status2 dp_Res2
  127. #define dp_BufAddr dp_Arg1
  128.    LONG dp_Arg1;
  129.    LONG dp_Arg2;
  130.    LONG dp_Arg3;
  131.    LONG dp_Arg4;
  132.    LONG dp_Arg5;
  133.    LONG dp_Arg6;
  134.    LONG dp_Arg7;
  135. }; /* DosPacket */
  136.  
  137. /* A Packet does not require the Message to be before it in memory, but
  138.  * for convenience it is useful to associate the two.
  139.  * Also see the function init_std_pkt for initializing this structure */
  140.  
  141. struct StandardPacket {
  142.    struct Message   sp_Msg;
  143.    struct DosPacket sp_Pkt;
  144. }; /* StandardPacket */
  145.  
  146. /* Packet types */
  147. #define ACTION_NIL        0
  148. #define ACTION_STARTUP        0
  149. #define ACTION_GET_BLOCK    2    /* OBSOLETE */
  150. #define ACTION_SET_MAP        4
  151. #define ACTION_DIE        5
  152. #define ACTION_EVENT        6
  153. #define ACTION_CURRENT_VOLUME    7
  154. #define ACTION_LOCATE_OBJECT    8
  155. #define ACTION_RENAME_DISK    9
  156. #define ACTION_WRITE        'W'
  157. #define ACTION_READ        'R'
  158. #define ACTION_FREE_LOCK    15
  159. #define ACTION_DELETE_OBJECT    16
  160. #define ACTION_RENAME_OBJECT    17
  161. #define ACTION_MORE_CACHE    18
  162. #define ACTION_COPY_DIR        19
  163. #define ACTION_WAIT_CHAR    20
  164. #define ACTION_SET_PROTECT    21
  165. #define ACTION_CREATE_DIR    22
  166. #define ACTION_EXAMINE_OBJECT    23
  167. #define ACTION_EXAMINE_NEXT    24
  168. #define ACTION_DISK_INFO    25
  169. #define ACTION_INFO        26
  170. #define ACTION_FLUSH        27
  171. #define ACTION_SET_COMMENT    28
  172. #define ACTION_PARENT        29
  173. #define ACTION_TIMER        30
  174. #define ACTION_INHIBIT        31
  175. #define ACTION_DISK_TYPE    32
  176. #define ACTION_DISK_CHANGE    33
  177. #define ACTION_SET_DATE        34
  178.  
  179. #define ACTION_SCREEN_MODE    994
  180.  
  181. #define ACTION_READ_RETURN    1001
  182. #define ACTION_WRITE_RETURN    1002
  183. #define ACTION_SEEK        1008
  184. #define ACTION_FINDUPDATE    1004
  185. #define ACTION_FINDINPUT    1005
  186. #define ACTION_FINDOUTPUT    1006
  187. #define ACTION_END        1007
  188. #define ACTION_SET_FILE_SIZE    1022    /* fast file system only in 1.3 */
  189. #define ACTION_WRITE_PROTECT    1023    /* fast file system only in 1.3 */
  190.  
  191. /* new 2.0 packets */
  192. #define ACTION_SAME_LOCK    40
  193. #define ACTION_CHANGE_SIGNAL    995
  194. #define ACTION_FORMAT        1020
  195. #define ACTION_MAKE_LINK    1021
  196. /**/
  197. /**/
  198. #define ACTION_READ_LINK    1024
  199. #define ACTION_FH_FROM_LOCK    1026
  200. #define ACTION_IS_FILESYSTEM    1027
  201. #define ACTION_CHANGE_MODE    1028
  202. /**/
  203. #define ACTION_COPY_DIR_FH    1030
  204. #define ACTION_PARENT_FH    1031
  205. #define ACTION_EXAMINE_ALL    1033
  206. #define ACTION_EXAMINE_FH    1034
  207.  
  208. #define ACTION_LOCK_RECORD    2008
  209. #define ACTION_FREE_RECORD    2009
  210.  
  211. #define ACTION_ADD_NOTIFY    4097
  212. #define ACTION_REMOVE_NOTIFY    4098
  213.  
  214. /*
  215.  * A structure for holding error messages - stored as array with error == 0
  216.  * for the last entry.
  217.  */
  218. struct ErrorString {
  219.     LONG  *estr_Nums;
  220.     UBYTE *estr_Strings;
  221. };
  222.  
  223. /* DOS library node structure.
  224.  * This is the data at positive offsets from the library node.
  225.  * Negative offsets from the node is the jump table to DOS functions
  226.  * node = (struct DosLibrary *) OpenLibrary( "dos.library" .. )         */
  227.  
  228. struct DosLibrary {
  229.     struct Library dl_lib;
  230.     struct RootNode *dl_Root; /* Pointer to RootNode, described below */
  231.     APTR    dl_GV;          /* Pointer to BCPL global vector          */
  232.     LONG    dl_A2;          /* Private register dump of DOS          */
  233.     LONG    dl_A5;
  234.     LONG    dl_A6;
  235.     struct ErrorString *dl_Errors;  /* pointer to array of error msgs */
  236.     struct timerequest *dl_TimeReq; /* private pointer to timer request */
  237.     struct Library     *dl_UtilityBase; /* private ptr to utility library */
  238. };  /*    DosLibrary */
  239.  
  240. /*                   */
  241.  
  242. struct RootNode {
  243.     BPTR    rn_TaskArray;         /* [0] is max number of CLI's
  244.                       * [1] is APTR to process id of CLI 1
  245.                       * [n] is APTR to process id of CLI n */
  246.     BPTR    rn_ConsoleSegment; /* SegList for the CLI               */
  247.     struct  DateStamp rn_Time; /* Current time                   */
  248.     LONG    rn_RestartSeg;     /* SegList for the disk validator process   */
  249.     BPTR    rn_Info;           /* Pointer to the Info structure           */
  250.     BPTR    rn_FileHandlerSegment; /* segment for a file handler       */
  251.     struct MinList rn_CliList; /* new list of all CLI processes */
  252.                    /* the first cpl_Array is also rn_TaskArray */
  253.     struct MsgPort *rn_BootProc; /* private ptr to msgport of boot fs       */
  254.     BPTR    rn_ShellSegment;   /* seglist for Shell (for NewShell)       */
  255.     LONG    rn_Flags;           /* dos flags */
  256. };  /* RootNode */
  257.  
  258. #define RNB_WILDSTAR    24
  259. #define RNF_WILDSTAR    (1L<<24)
  260. #define RNB_PRIVATE1    1    /* private for dos */
  261. #define RNF_PRIVATE1    2
  262.  
  263. /* ONLY to be allocated by DOS! */
  264. struct CliProcList {
  265.     struct MinNode cpl_Node;
  266.     LONG cpl_First;         /* number of first entry in array */
  267.     struct MsgPort **cpl_Array;
  268.                  /* [0] is max number of CLI's in this entry (n)
  269.                   * [1] is CPTR to process id of CLI cpl_First
  270.                   * [n] is CPTR to process id of CLI cpl_First+n-1
  271.                   */
  272. };
  273.  
  274. struct DosInfo {
  275.     BPTR    di_McName;           /* PRIVATE: system resident module list        */
  276. #define di_ResList di_McName
  277.     BPTR    di_DevInfo;           /* Device List                    */
  278.     BPTR    di_Devices;           /* Currently zero                */
  279.     BPTR    di_Handlers;       /* Currently zero                */
  280.     APTR    di_NetHand;           /* Network handler processid; currently zero */
  281.     struct  SignalSemaphore di_DevLock;       /* do NOT access directly! */
  282.     struct  SignalSemaphore di_EntryLock;  /* do NOT access directly! */
  283.     struct  SignalSemaphore di_DeleteLock; /* do NOT access directly! */
  284. };  /* DosInfo */
  285.  
  286. /* structure for the Dos resident list.  Do NOT allocate these, use      */
  287. /* AddSegment(), and heed the warnings in the autodocs!              */
  288.  
  289. struct Segment {
  290.     BPTR seg_Next;
  291.     LONG seg_UC;
  292.     BPTR seg_Seg;
  293.     UBYTE seg_Name[4];    /* actually the first 4 chars of BSTR name */
  294. };
  295.  
  296. #define CMD_SYSTEM    -1
  297. #define CMD_INTERNAL    -2
  298. #define CMD_DISABLED    -999
  299.  
  300.  
  301. /* DOS Processes started from the CLI via RUN or NEWCLI have this additional
  302.  * set to data associated with them */
  303.  
  304. struct CommandLineInterface {
  305.     LONG   cli_Result2;           /* Value of IoErr from last command      */
  306.     BSTR   cli_SetName;           /* Name of current directory          */
  307.     BPTR   cli_CommandDir;     /* Head of the path locklist          */
  308.     LONG   cli_ReturnCode;     /* Return code from last command          */
  309.     BSTR   cli_CommandName;    /* Name of current command          */
  310.     LONG   cli_FailLevel;      /* Fail level (set by FAILAT)          */
  311.     BSTR   cli_Prompt;           /* Current prompt (set by PROMPT)      */
  312.     BPTR   cli_StandardInput;  /* Default (terminal) CLI input          */
  313.     BPTR   cli_CurrentInput;   /* Current CLI input              */
  314.     BSTR   cli_CommandFile;    /* Name of EXECUTE command file          */
  315.     LONG   cli_Interactive;    /* Boolean; True if prompts required      */
  316.     LONG   cli_Background;     /* Boolean; True if CLI created by RUN      */
  317.     BPTR   cli_CurrentOutput;  /* Current CLI output              */
  318.     LONG   cli_DefaultStack;   /* Stack size to be obtained in long words */
  319.     BPTR   cli_StandardOutput; /* Default (terminal) CLI output          */
  320.     BPTR   cli_Module;           /* SegList of currently loaded command      */
  321. };  /* CommandLineInterface */
  322.  
  323. /* This structure can take on different values depending on whether it is
  324.  * a device, an assigned directory, or a volume.  Below is the structure
  325.  * reflecting volumes only.  Following that is the structure representing
  326.  * only devices. Following that is the unioned structure representing all
  327.  * the values
  328.  */
  329.  
  330. /* structure representing a volume */
  331.  
  332. struct DeviceList {
  333.     BPTR        dl_Next;    /* bptr to next device list */
  334.     LONG        dl_Type;    /* see DLT below */
  335.     struct MsgPort *    dl_Task;    /* ptr to handler task */
  336.     BPTR        dl_Lock;    /* not for volumes */
  337.     struct DateStamp    dl_VolumeDate;    /* creation date */
  338.     BPTR        dl_LockList;    /* outstanding locks */
  339.     LONG        dl_DiskType;    /* 'DOS', etc */
  340.     LONG        dl_unused;
  341.     BSTR        dl_Name;    /* bptr to bcpl name */
  342. };
  343.  
  344. /* device structure (same as the DeviceNode structure in filehandler.h) */
  345.  
  346. struct          DevInfo {
  347.     BPTR  dvi_Next;
  348.     LONG  dvi_Type;
  349.     APTR  dvi_Task;
  350.     BPTR  dvi_Lock;
  351.     BSTR  dvi_Handler;
  352.     LONG  dvi_StackSize;
  353.     LONG  dvi_Priority;
  354.     LONG  dvi_Startup;
  355.     BPTR  dvi_SegList;
  356.     BPTR  dvi_GlobVec;
  357.     BSTR  dvi_Name;
  358. };
  359.  
  360. /* combined structure for devices, assigned directories, volumes */
  361.  
  362. struct DosList {
  363.     BPTR        dol_Next;     /* bptr to next device on list */
  364.     LONG        dol_Type;     /* see DLT below */
  365.     struct MsgPort     *dol_Task;     /* ptr to handler task */
  366.     BPTR        dol_Lock;
  367.     union {
  368.     struct {
  369.     BSTR    dol_Handler;    /* file name to load if seglist is null */
  370.     LONG    dol_StackSize;    /* stacksize to use when starting process */
  371.     LONG    dol_Priority;    /* task priority when starting process */
  372.     ULONG    dol_Startup;    /* startup msg: FileSysStartupMsg for disks */
  373.     BPTR    dol_SegList;    /* already loaded code for new task */
  374.     BPTR    dol_GlobVec;    /* BCPL global vector to use when starting
  375.                  * a process. -1 indicates a C/Assembler
  376.                  * program. */
  377.     } dol_handler;
  378.  
  379.     struct {
  380.     struct DateStamp    dol_VolumeDate;     /* creation date */
  381.     BPTR            dol_LockList;     /* outstanding locks */
  382.     LONG            dol_DiskType;     /* 'DOS', etc */
  383.     } dol_volume;
  384.  
  385.     struct {
  386.     UBYTE    *dol_AssignName;     /* name for non-or-late-binding assign */
  387.     struct AssignList *dol_List; /* for multi-directory assigns (regular) */
  388.     } dol_assign;
  389.  
  390.     } dol_misc;
  391.  
  392.     BSTR        dol_Name;     /* bptr to bcpl name */
  393.     };
  394.  
  395. /* structure used for multi-directory assigns. AllocVec()ed. */
  396.  
  397. struct AssignList {
  398.     struct AssignList *al_Next;
  399.     BPTR           al_Lock;
  400. };
  401.  
  402. /* definitions for dl_Type */
  403. #define DLT_DEVICE    0
  404. #define DLT_DIRECTORY    1    /* assign */
  405. #define DLT_VOLUME    2
  406. #define DLT_LATE    3    /* late-binding assign */
  407. #define DLT_NONBINDING    4    /* non-binding assign */
  408. #define DLT_PRIVATE    -1    /* for internal use only */
  409.  
  410. /* structure return by GetDeviceProc() */
  411. struct DevProc {
  412.     struct MsgPort *dvp_Port;
  413.     BPTR        dvp_Lock;
  414.     ULONG        dvp_Flags;
  415.     struct DosList *dvp_DevNode;    /* DON'T TOUCH OR USE! */
  416. };
  417.  
  418. /* definitions for dvp_Flags */
  419. #define DVPB_UNLOCK    0
  420. #define DVPF_UNLOCK    (1L << DVPB_UNLOCK)
  421. #define DVPB_ASSIGN    1
  422. #define DVPF_ASSIGN    (1L << DVPB_ASSIGN)
  423.  
  424. /* Flags to be passed to LockDosList(), etc */
  425. #define LDB_DEVICES    2
  426. #define LDF_DEVICES    (1L << LDB_DEVICES)
  427. #define LDB_VOLUMES    3
  428. #define LDF_VOLUMES    (1L << LDB_VOLUMES)
  429. #define LDB_ASSIGNS    4
  430. #define LDF_ASSIGNS    (1L << LDB_ASSIGNS)
  431. #define LDB_ENTRY    5
  432. #define LDF_ENTRY    (1L << LDB_ENTRY)
  433. #define LDB_DELETE    6
  434. #define LDF_DELETE    (1L << LDB_DELETE)
  435.  
  436. /* you MUST specify one of LDF_READ or LDF_WRITE */
  437. #define LDB_READ    0
  438. #define LDF_READ    (1L << LDB_READ)
  439. #define LDB_WRITE    1
  440. #define LDF_WRITE    (1L << LDB_WRITE)
  441.  
  442. /* actually all but LDF_ENTRY (which is used for internal locking) */
  443. #define LDF_ALL        (LDF_DEVICES|LDF_VOLUMES|LDF_ASSIGNS)
  444.  
  445. /* a lock structure, as returned by Lock() or DupLock() */
  446. struct FileLock {
  447.     BPTR        fl_Link;    /* bcpl pointer to next lock */
  448.     LONG        fl_Key;        /* disk block number */
  449.     LONG        fl_Access;    /* exclusive or shared */
  450.     struct MsgPort *    fl_Task;    /* handler task's port */
  451.     BPTR        fl_Volume;    /* bptr to DLT_VOLUME DosList entry */
  452. };
  453.  
  454. /* error report types for ErrorReport() */
  455. #define REPORT_STREAM        0    /* a stream */
  456. #define REPORT_TASK        1    /* a process - unused */
  457. #define REPORT_LOCK        2    /* a lock */
  458. #define REPORT_VOLUME        3    /* a volume node */
  459. #define REPORT_INSERT        4    /* please insert volume */
  460.  
  461. /* Special error codes for ErrorReport() */
  462. #define ABORT_DISK_ERROR    296    /* Read/write error */
  463. #define ABORT_BUSY        288    /* You MUST replace... */
  464.  
  465. /* types for initial packets to shells from run/newcli/execute/system. */
  466. /* For shell-writers only */
  467. #define RUN_EXECUTE        -1
  468. #define RUN_SYSTEM        -2
  469. #define RUN_SYSTEM_ASYNCH    -3
  470.  
  471. /* Types for fib_DirEntryType.    NOTE that both USERDIR and ROOT are     */
  472. /* directories, and that directory/file checks should use <0 and >=0.     */
  473. /* This is not necessarily exhaustive!    Some handlers may use other     */
  474. /* values as needed, though <0 and >=0 should remain as supported as     */
  475. /* possible.                                 */
  476. #define ST_ROOT        1
  477. #define ST_USERDIR    2
  478. #define ST_SOFTLINK    3    /* looks like dir, but may point to a file! */
  479. #define ST_LINKDIR    4    /* hard link to dir */
  480. #define ST_FILE        -3    /* must be negative for FIB! */
  481. #define ST_LINKFILE    -4    /* hard link to file */
  482.  
  483. #endif    /* DOS_DOSEXTENS_H */
  484.